//
//  YQServerTermsView.m
//  NewRetail
//
//  Created by yuqin on 2019/6/30.
//  Copyright © 2019年 yuqin. All rights reserved.
//

#import "YQServerTermsView.h"

@interface YQServerTermsView () 

@property (nonatomic, strong) UIButton *chooseBtn;//选中框
@property (nonatomic, strong) UILabel *describeLab;//文字
@property (nonatomic, strong) UIButton *serverBtn;//服务框

@end

@implementation YQServerTermsView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor = [UIColor clearColor];
        [self createView];
    }
    return self;
}

- (void)createView {
    [self addSubview:self.chooseBtn];
    [self addSubview:self.describeLab];
    [self addSubview:self.serverBtn];
    
    [self.chooseBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(kMargin_left);
        make.top.mas_equalTo(0);
        make.size.mas_equalTo(CGSizeMake(FIT(15), FIT(15)));
    }];
    
    [self.describeLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.chooseBtn.mas_right).mas_equalTo(FIT(5));
        make.centerY.equalTo(self.chooseBtn.mas_centerY);
    }];
    
    [self.serverBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.describeLab.mas_right).mas_equalTo(FIT(5));
        make.centerY.equalTo(self.chooseBtn.mas_centerY);
    }];
    
}

- (UIButton *)chooseBtn {
    if (!_chooseBtn) {
        _chooseBtn = [YQViewFactory buttonWithImage:YQ_IMAGE(@"normal") target:self sel:@selector(chooseAction:)];
        [_chooseBtn setImage:YQ_IMAGE(@"gouxuan") forState:UIControlStateSelected];
        [_chooseBtn setBackgroundColor:MainRedTextColor];
        _chooseBtn.selected = YES;
    }
    return _chooseBtn;
}

- (UILabel *)describeLab {
    if (!_describeLab) {
        _describeLab = [YQViewFactory labelWithTextColor:[UIColor grayColor] textAlignment:NSTextAlignmentLeft fontSize:kLittleFont userBold:NO];
        _describeLab.text = @"我已仔细阅读并同意";
    }
    return _describeLab;
}

- (UIButton *)serverBtn {
    if (!_serverBtn) {
        _serverBtn = [YQViewFactory buttonWithTitle:@"《服务及隐私条款》" titleColor:MainBlueColor fontSize:kLittleFont userBold:NO target:self sel:@selector(serverAction)];
    }
    return _serverBtn;
}

- (void)chooseAction:(UIButton *)sender {
    //勾选
    sender.selected = !sender.selected;
}

- (void)serverAction {
    //点击跳转
}

@end
